package com.zmn.oms.dubbo.impl.zmn.bcustomer.order;

import org.apache.dubbo.config.annotation.Service;
import com.zmn.common.dto.ResponseDTO;
import com.zmn.common.utils.reflect.BeanMapper;
import com.zmn.common.utils.response.ResponseUtil;
import com.zmn.oms.dubbo.dto.zmn.order.OrderScheduleDayDRO;
import com.zmn.oms.dubbo.dto.zmn.order.OrderScheduleTimeDRO;
import com.zmn.oms.dubbo.interfaces.zmn.bcustomer.order.ZsBCustomerOrderScheduleRemoteService;
import com.zmn.oms.dubbo.utils.DubboConsts;
import com.zmn.oms.model.vo.work.schedule.OrderScheduleVO;
import com.zmn.oms.model.vo.work.schedule.ScheduleDayVo;
import com.zmn.oms.zmn.business.interfaces.work.ZsOrderWorkScheduleBService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;
import java.util.Objects;

/** 
 * 类描述：大客户单预约时间
 * 
 * @author  liuying
 * @date   2019/01/08 15:35
 */
@Service(loadbalance = "roundrobin", timeout = 5000, retries = 2, version = DubboConsts.INTERFACE_VERSION, validation = "false")
public class ZsBCustomerOrderScheduleRemoteServiceImpl implements ZsBCustomerOrderScheduleRemoteService {

    private static final String TAG = "啄木鸟-大客户-预约时间";
    private Logger logger = LoggerFactory.getLogger(ZsBCustomerOrderScheduleRemoteServiceImpl.class);

    @Autowired
    private ZsOrderWorkScheduleBService zsOrderWorkScheduleBService;

    @Override
    public ResponseDTO<OrderScheduleDayDRO> getScheduleDayList() {
        try {
            List<ScheduleDayVo> scheduleDayVoList = zsOrderWorkScheduleBService.getScheduleDayList();
            List<OrderScheduleDayDRO> droList = BeanMapper.mapList(scheduleDayVoList, OrderScheduleDayDRO.class);
            return ResponseUtil.responseSuccessItems(droList);
        } catch (Exception e) {
            e.printStackTrace();
            return ResponseUtil.responseFail(e.getMessage());
        }
    }

    @Override
    public ResponseDTO<OrderScheduleTimeDRO> getScheduleTimes(String scheDate) {
        Objects.requireNonNull(scheDate, "预约日期不能为空");
        try {
            OrderScheduleVO orderScheduleVO = zsOrderWorkScheduleBService.getScheduleTimes(scheDate, null);
            OrderScheduleTimeDRO orderScheduleTimeDRO = BeanMapper.map(orderScheduleVO, OrderScheduleTimeDRO.class);
            return ResponseUtil.responseSuccessData(orderScheduleTimeDRO);
        } catch (Exception e) {
            e.printStackTrace();
            return ResponseUtil.responseFail(e.getMessage());
        }
    }
}
